﻿using Prism.Commands;
using Prism.Events;
using Prism.Mvvm;
using Prism.Navigation.Regions;
using RoboAssembleX.Application.Common;
using RoboAssembleX.Application.Robot;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;

namespace RoboAssembleX.ViewModels
{
    public class ViewTopViewModel: BindableBase
    {
        private readonly IRegionManager regionManager;
        private readonly IEventAggregator eventAggregator;

        public DelegateCommand<string> MenuCommand { get; private set; }

        public ViewTopViewModel(IRegionManager regionManager, IEventAggregator eventAggregator )
        {
            MenuCommand = new DelegateCommand<string>(MenuMethod);
            this.regionManager = regionManager;
            this.eventAggregator = eventAggregator;
        }

        private void MenuMethod(string menuName)
        {
            if (menuName == "Exit")
            {
                
                eventAggregator.GetEvent<WindowsCloseEvent>().Publish();
                return;
            }
            var v = regionManager.Regions["MainRegion"];
            v.RequestNavigate(menuName);
        }
    }
}
